# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=process-cpp
pkgver=3.0.1
pkgrel=4
pkgdesc="A simple convenience library for handling processes in C++11"
url="https://gitlab.com/ubports/core/lib-cpp/process-cpp"
arch="all"
license="LGPL-3.0-only"
depends_dev="properties-cpp-dev"
makedepends="$depends_dev cmake cmake-extras boost-dev libexecinfo-dev gtest-dev"
subpackages="$pkgname-dev"
source="https://gitlab.com/ubports/core/lib-cpp/process-cpp/-/archive/$pkgver/process-cpp-$pkgver.tar.gz
	0001-Musl-libc-fixes.patch"
options="!check" # Tests are randomly failing

libatomic=""
[ "$CARCH" = "riscv64" ] && libatomic="-latomic"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	LDFLAGS="$LDFLAGS $libatomic" cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E "linux_process_test"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="4a96d57ea211a264f088c3bebd42a8a5603ed6652d7731ff9b05190c2c71b4e4c9e65164475530fbe5cf6a77f6441cf92b00680ea61b9274a91921bb76c11e88  process-cpp-3.0.1.tar.gz
97b2a54e52b8f6a1839cfcdc6fb401768d731bacbe6bc920b511777e72806d844cded9ad9222b570e46cdbf692def363128c4cb4e2e291fcd4f66c081ad0c5cd  0001-Musl-libc-fixes.patch"
